package com.jh.user.pojo.enums;

/**
 * 交易类型枚举
 *
 * @author Yichuan
 * @version 1.0
 */
public enum PayType {

    TRADE(1, "交易"),

    WITHDRAW(2, "代还"),

    WITHDRAW_(3, "提现"),

    ;

    final short value;
    final String desc;

    PayType(int value, String desc) {
        this.value = (short) value;
        this.desc = desc;
    }

    public short getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    public static <T extends Number> PayType of(T n) {
        short val;
        if (n == null || (val = n.shortValue()) < 0) {
            return null;
        }
        for (PayType payType: values()) {
            if (payType.getValue() == val)
                return payType;
        }
        return null;
    }
}
